#ifndef DIALOG_CFDY_H
#define DIALOG_CFDY_H

#include <QDialog>
#include <QSqlQuery>
#include <QPrinter>
#include <QPainter>
#include <QMap>
#include <QTimer>
#include <QAxObject>
#include <QProcess>
#include <QSoundEffect>

#include "tj_form_barcode_return.h"

#include "yb_form_qlsjsc.h"

namespace Ui {
class Dialog_cfdy;
}

class Dialog_cfdy : public QDialog
{
    Q_OBJECT

public:

    explicit Dialog_cfdy(QWidget *parent = nullptr);
    ~Dialog_cfdy();

    void print_single_recipe();
    void printPage(QString recipe_type = "处方");
    void savePrintStatus(QString);
    void processData(QString);
    void tfPrint();
    void print_undrug(QString invoice_no);
    QString get_tr_diag(QString med_diag, QString clinic_code);

signals:

    void destroyW(QString);

private slots:
    void closeEvent(QCloseEvent *event);
    void tm_print_undrug_timer();//延时启动非药品处方打印
    void on_pbSinglePrint_clicked();
    void onTimerOut();
    void on_pbStop_clicked();
    void on_pbStart_clicked();
    void on_pbSearch_clicked();
    void on_pbTf_clicked();
    void on_pbBldy_clicked();

    void on_lwYfy_clicked(const QModelIndex &index);
    void on_lwYfy_doubleClicked(const QModelIndex &index);
    void on_pbExit_clicked();
    void on_leSjh_returnPressed();
    void on_rbF_clicked();
    void on_rbB_clicked();
    void on_pbDisplay_clicked();

    void cbbTerminalTextChanged(QString arg1);

    void on_rbX_clicked();

    void on_pbTfzh_clicked();

    void on_pb_undrug_print_clicked();

    void on_pushButton_2_clicked();

    void on_pb_bill_list_output_clicked();

    void on_cbbCheck_currentTextChanged(const QString &arg1);

    void on_cbbDelivery_currentTextChanged(const QString &arg1);

    void on_pb_cancel_bill_search_clicked();

private:
    Ui::Dialog_cfdy *ui;

    tj_form_barcode_return * barcode_return;
    QSqlQuery *qrm,*qrmt, *qro, *qrot, *qro_undrug0, *qro_undrug1;
    QPrinter *prt;
    QPainter *pnt;
    bool acceptListClicked;
    int count;
    float ptScale;  //for printer, mm to point covnert.
    float fScale;
    QMap<QString,QString> mpPage, mp_page_undrug;
    QTimer * tm;
    QTimer * tm_print_undrug;
    int timerCount; //定时中断次数，确定调用数据库查询间隔
    int stock_timer_count;//进销存,库存查询周期
    QString terminalCode,terminalName,deptCode;//工作窗口代码,科室代码
    QString clinicCode, doctName; //门诊号，医生姓名，打印退费单需要
    QString deptName; //就诊科室
    //QString officeOper; //dslFramer ,office operation need.
    QString cfPrinter, bzPrinter;
    QString  druged_oper_code, send_oper_code;  //调配与付药

    QString undrug_dept;//需要打印非药品处方的诊室
    QString undrug_invo_no; //即将被打印的非药品处方发票号

    QProcess *zint_proc ;

    QSoundEffect snd_new_recipe ;

    Form_qlsjsc * jxc;  //进销存

    QString patient_name;

};

#endif // DIALOG_CFDY_H
